﻿using IceDog.WebApi.ConventionalRoute.Models;
using System;
using System.Collections.Generic;
using System.Linq;

namespace IceDog.WebApi.ConventionalRoute.DBData
{
    /// <summary>
    /// 
    /// </summary>
    public class DbInitializer
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public static void Initialize(ShopContext context)
        {
            if (context.Orders.Any())
            {
                return;
            }
            var ran = new Random();
            for (int i = 1; i <= 10; i++)
            {
                context.Orders.Add(new Order()
                {
                    Id=i,
                    OrderDate=DateTime.Now.AddDays(ran.Next(-100,-1)),
                    Description = "Apple Pie x "+i,
                    Total =ran.Next(10,100),
                    Remark= "afternoon tea"
                });
            }
            context.SaveChanges();
        }
    }
}
